<template>
  <!--  带边框的样式  -->
  <el-form
    ref="form"
    :model="formData"
    :label-width="labelWidth + 'px'"
    size="mini"
    @submit.native.prevent
  >
    <el-row>
      <el-col
        v-for="(item, index) in detailsList"
        :key="index"
        :span="item.span ? item.span : 24"
      >
        <el-form-item
          v-if="item.type == 'slot'"
          :label="item.label"
        >
          <slot
            :name="item.field"
            :value="formData[item.field]"
          />
        </el-form-item>
        <el-form-item
          v-else
          :label="item.label"
        >
          <template #label="scope">
            <el-tooltip
              class="item"
              effect="light"
              :content="item.label+''"
              placement="top-end"
            >
              <el-button
                class="btn-content-label"
                style="color:#606266 !important;text-align:right;padding:0 10px;"
                type="text"
              >{{
                item.label
              }}
              </el-button>
            </el-tooltip>
          </template>
          <el-tooltip
            v-if="formData[item.field]!=null && formData[item.field]!=''"
            class="item"
            effect="dark"
            placement="top-start"
          >
            <template slot="content">
              <!--              :content="formData[item.field]!=null?formData[item.field]+'':''"-->
              <span>{{ formData[item.field]+'' }}</span>
            </template>
            <el-button
              class="btn-content"
              style="color:#606266 !important;padding:0 10px;"
              type="text"
            >{{
              formData[item.field]
            }}
            </el-button>
          </el-tooltip>
          <div v-else />
        </el-form-item>
      </el-col>
    </el-row>
  </el-form>
</template>

<script>
export default {
  name: 'HkDetails',
  props: {
    labelWidth: {
      type: String,
      default() {
        return '100'
      }
    },
    detailsList: {
      type: Array,
      default() {
        return []
      }
    },
    formData: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  data() {
    return {}
  },
  watch: {
    formData: {
      handler(newVal) {

      }
    }
  },
  methods: {}
}
</script>

<style lang="scss" scoped>
#app.dark-theme ~ .el-dialog__wrapper .el-form-item {
  border-top: 1px solid rgba(59, 139, 255, 0.4) !important;
  border-bottom: 1px solid rgba(59, 139, 255, 0.4) !important;
}
.flex-row {
  display: flex;
  flex-wrap: wrap;
}
::v-deep .el-form-item {
  margin-bottom: 0 !important;
  border-top: 1px solid #e5e5e5;
  border-bottom: 1px solid #e5e5e5;
  margin-top: -1px;
}

::v-deep .el-form-item__label {
  background: #f9fafd !important;
  font-weight: 100;
  line-height: 30px;
}

::v-deep .el-form-item__content {
  overflow: hidden; //溢出隐藏
  white-space: nowrap; //禁止换行
  text-overflow: ellipsis; //...
}

::v-deep .btn-content {
  width: 100%;
  span {
    width: 100%;
    text-align: left;
    font-size: 14px !important;
    display: inline-block !important;
    overflow: hidden !important; //溢出隐藏
    white-space: nowrap !important; //禁止换行
    text-overflow: ellipsis !important; //...
  }
}
::v-deep .btn-content-label {
  width: 100%;
  span {
    width: 100%;
    font-size: 14px;
    display: inline-block !important;
    overflow: hidden !important; //溢出隐藏
    white-space: nowrap !important; //禁止换行
    text-overflow: ellipsis !important; //...
  }
}
</style>
